import HTTP from '@/plugins/axios'
import { api } from '@/ts/enum'
import { dealRes, pageList } from '@/ts/type'
import { User, UserDto } from '@/ts/type/User'

const UserService = class UserService {
  static getUserInfoList(page: number, size: number) {
    return HTTP.get<dealRes<pageList<UserDto>>>(`/${api.UserApi}/${page}/${size}`)
  }

  static queryUser(page: number, size: number, data: User) {
    return HTTP.post<dealRes<pageList<UserDto>>>(`/${api.UserApi}/query/${page}/${size}`, data)
  }

  static deleteUser(userId: number) {
    return HTTP.delete<dealRes<string>>(`/${api.UserApi}/${userId}`)
  }

  static getUserById(userId: number) {
    return HTTP.get<dealRes<User>>(`/${api.UserApi}/${userId}`)
  }

  static putUser(data: User) {
    return HTTP.put<dealRes<string>>(`/${api.UserApi}`, data)
  }

  static postUser(data: User) {
    return HTTP.post<dealRes<string>>(`/${api.UserApi}`, data)
  }
}

export default UserService